package com.yangjie.common.dao.criteria;

import org.hibernate.criterion.Order;

public class OrderByExpression {
	public static final String ORDER_ASC = "ASC";
	public static final String ORDER_DESC = "DESC";
	private String fieldName = null;
	private String order = ORDER_DESC;
	
	public OrderByExpression(String fieldName, String order) {
		this.fieldName = fieldName;
		this.order = order;
	}
	public String getFieldName() {
		return fieldName;
	}
	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}
	public String getOrder() {
		return order;
	}
	public void setOrder(String order) {
		this.order = order;
	}
	
	public Order toHbnOrder() {
		if(ORDER_ASC.equalsIgnoreCase(order)) {
			return Order.asc(fieldName);
		} else {
			return Order.desc(fieldName);
		}
	}
	
}
